<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>BFC解决问题1-margin重合</title>
  <style>
    .container {
      
      overflow:hidden
    }
    .box {
      width: 300px;
      height: 300px;
    }

    .box1 {
      background-color: lightpink;
      margin-bottom: 30px;
    }

    .box2 {
      background-color: lightgreen;
      margin-top: 30px;
    }
  </style>
</head>

<body>
  <!-- BFC的子元素不会对外面的元素产生影响 -->
  <div class="container">
    <div class="box box1"></div>
  </div>

  <div class="container">
    <div class="box box2"></div>
  </div>
</body>

</html>